package fun.liuyu2783.txmessage.marketing.mq;

import fun.liuyu2783.txmessage.common.MqConstant;
import fun.liuyu2783.txmessage.marketing.dto.Trade;
import fun.liuyu2783.txmessage.marketing.service.CouponService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RocketMQMessageListener(topic = MqConstant.TOPIC_TRADE_TRANSACTION, consumerGroup = "marketing_trade_transaction_customer_group")
public class TradeTransactionConsumer implements RocketMQListener<Trade> {

    @Autowired
    private CouponService couponService;

    @Override
    public void onMessage(Trade trade) {
        log.info("接收到订单创建消息：{}", trade);
        couponService.add(trade.getId());
    }

}
